﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Student> list = new List<Student>();
            Hashtable ht = new Hashtable();

            Student s1 = new Student("狗一", 1, 28);
            Student s4 = new Student("狗二", 2, 20);
            Student s3 = new Student("狗三", 3, 19);
            Student s2 = new Student("狗四", 4, 30);


            ht.Add(s1.Stuno, s1);
            ht.Add(s4.Stuno, s4);
            ht.Add(s3.Stuno, s3);
            ht.Add(s2.Stuno, s2);
            list.Add(s1);
            list.Add(s4);
            list.Add(s3);
            list.Add(s2);

            Console.WriteLine("请选择：1、添加学生信息。2、查询学生信息，3、删除学生信息  4、退出");
            int asd = int.Parse(Console.ReadLine());

            switch (asd)
            {
                case 1:
                    Student s6 = new Student();
                    Console.WriteLine("请输入姓名");
                    s6.Name = Console.ReadLine();
                    Console.WriteLine("请输入学号");
                    s6.Stuno = int.Parse(Console.ReadLine());
                    Console.WriteLine("请输入年龄");
                    s6.Age = int.Parse(Console.ReadLine());
                    ht.Add(s6.Stuno, s6);
                    list.Add(s6);
                    break;
                case 2:
                    Console.WriteLine(@"1、查询所有（按学号排序）2、查询所有（按姓名排序），2、查询所有（按年龄排序）4、按学号查询（查没有，则打印查无此学生）5、退出
");
                    int num1 = int.Parse(Console.ReadLine());
                    switch (num1)
                    {
                        case 1:
                            list.Sort(new Stuno());
                            foreach (var item in ht.Values)
                            {
                                Console.WriteLine(item);
                            }
                            
                            
                            break;
                        case 2:
                            list.Sort(new Stuname());
                            foreach (var item in ht.Values)
                            {
                                Console.WriteLine(item);
                            }
                            break;
                        case 3:
                            list.Sort(new Stuage());
                            foreach (var item in ht.Values)
                            {
                                Console.WriteLine(item);
                            }
                            break;
                        case 4:
                            Console.Write("请输入你的学号：");
                            int Id = int.Parse(Console.ReadLine());

                            if (ht.Contains(Id))
                            {
                                Console.WriteLine("此学生已存在");
                            }
                            else
                            {
                                Console.WriteLine("查无此学生!!!");
                            }
                            break;
                        case 5:
                            break;
                        default:
                            break;
                    }
                    
                        
                  
                    break;
                case 3:
                    Console.WriteLine("请输入要删除信息的人的姓名");
                    string num3 = Console.ReadLine();
                    ht.Remove(num3);
                    break;
                case 4:
                    Environment.Exit(0);
                    break;
            }
        }
    }
    }

